package iedcyt.acute.dataAccess.factories;

import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import iedcyt.acute.dataAccess.dao.endnote.Discipline_PubDao;
import iedcyt.acute.dataAccess.dao.endnote.Ma0BisDao;
import iedcyt.acute.dataAccess.dao.endnote.REC_XmlDao;
import iedcyt.acute.dataAccess.dao.maauco.Ma0Dao;
import iedcyt.acute.dataAccess.idao.IDao;
import iedcyt.acute.dataAccess.idao.endnote.IDiscipline_PubDao;
import iedcyt.acute.dataAccess.idao.endnote.IMa0BisDao;
import iedcyt.acute.dataAccess.idao.endnote.IREC_XmlDao;
import iedcyt.acute.dataAccess.idao.maauco.IMa0Dao;
import iedcyt.acute.dataAccess.utils.BeansXML;
import iedcyt.acute.dataAccess.utils.Parameters;

/**
 * Acceso a los DAO de los datos para el tratamiento de la descarga de endnote. 
 * Ma0Bis, REC_Xml y Discipline_Pub
 * @author 53385255R
 *
 */
public class AbsendnoteFactoryDao extends AbsFactoryDao {

	
	private static AbsendnoteFactoryDao _instance;

	private IMa0BisDao _Ma0BisDao;
	private IREC_XmlDao _REC_XmlDao;
	private IDiscipline_PubDao _Discipline_PubDao;

	
	

	private AbsendnoteFactoryDao() {
		super();
		startDaos();
	}
	
	public static AbsendnoteFactoryDao getInstance() {
		if (_instance == null) _instance = new AbsendnoteFactoryDao();
		
		return _instance;
	}
	
	
	
	
	public IMa0BisDao get_Ma0BisDao() {
		return _Ma0BisDao;
	}
	
	@Override
	protected IDao getIDao() {
		return _Ma0BisDao;
	}
	
	public IDiscipline_PubDao get_Discipline_PubDao() {
		return _Discipline_PubDao;
	}
	
	public IREC_XmlDao get_REC_XmlDao() {
		return _REC_XmlDao;
	}

	

	/**
	 * @see iedcyt.acute.dataAccess.factories.AbsFactoryDao#startDaos()
	 */
	@Override
	public void startDaos() {
		AbstractApplicationContext _context = new FileSystemXmlApplicationContext(Parameters.get_instance().getBeanFile());
		_context.registerShutdownHook();
		_Ma0BisDao = ((Ma0BisDao) _context.getBean("ma0BisDao"));
		_Ma0BisDao.create();
		_REC_XmlDao = ((REC_XmlDao) _context.getBean("rEC_XmlDao"));
		_REC_XmlDao.create();
		_Discipline_PubDao = (Discipline_PubDao) _context.getBean("discipline_PubDao");
		_Discipline_PubDao.create();
		
	}
	
	/**
	 * @see iedcyt.acute.dataAccess.factories.AbsFactoryDao#getPath()
	 */
	@Override
	public String getPath() {
		return BeansXML.getInstance().getDatabasePath("endnoteDataSource");
		
	}
}
